import logging
import sqlite3

class NativeSqlite3Handle:
    def __init__(self, path):
        self.path = path
        self.conn = sqlite3.connect(self.path)

    def execute(self, sql):
        try:
            self.conn.cursor().execute(sql)
        except sqlite3.Error as err:
            logging.error(f"sql <'{sql}'> error")
            raise err

    def commit(self):
        self.conn.commit()

    def execute_commit(self, sql):
        self.execute(sql)
        self.commit()

    def insert(self, sql):
        self.execute_commit(sql)

    def update(self, sql):
        self.execute_commit(sql)